package teamworkYangXiaoCheng.ShiYanBao;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class App {
    public static void main(String[] args) throws Exception{
        //1.通过反射得到Cus的实例c
        //2.通过实例c的printRandomSerive的方法
        Class<?> C = Class.forName("teamworkYangXiaoCheng.ShiYanBao.CustomerService");
        Class<?> U = Class.forName("teamworkYangXiaoCheng.ShiYanBao.UserService");
        Object customerService = C.newInstance();
        Object userService = U.newInstance();
        Field service = C.getDeclaredField("service");//提取service属性的值
        service.setAccessible(true);
        service.set(customerService,userService);
        Method printRandomService = C.getMethod("printRandomService");
        printRandomService.invoke(customerService);
    }
}
